﻿using System;
using System.Windows.Forms;

namespace ruscehproj2
{
    public partial class bv009 : Form
    {
        bool isActive = false;
        bool nakalDalIsOn = false;
        bool nakalAzIsOn = false;

        public bool getState()
        {
            return isActive;
        }

        public bv009()
        {
            InitializeComponent();
        }

        private void dalOn_Click(object sender, EventArgs e)
        {
            if (FormManager.BK007.getState())
            {
                dalLight.BackgroundImage = Resources.grLight;
                dalLight.BackgroundImageLayout = ImageLayout.Stretch;
                nakalDalIsOn = true;
                if (nakalDalIsOn && nakalAzIsOn)
                {
                    FormManager.hlp.setHelpId("15");
                    FormManager.hlp.hlpRefresh();
                }
            }
        }

        private void dalOff_Click(object sender, EventArgs e)
        {
            /*
            dalLight.BackgroundImage = Resources.null256;
            dalLight.BackgroundImageLayout = ImageLayout.Stretch;
            isActive = false;
             */
        }

        private void azOn_Click(object sender, EventArgs e)
        {
            if (FormManager.BK007.getState())
            {
                azLight.BackgroundImage = Resources.grLight;
                azLight.BackgroundImageLayout = ImageLayout.Stretch;
                nakalAzIsOn = true;
                if (nakalDalIsOn && nakalAzIsOn)
                {
                    FormManager.hlp.setHelpId("15");
                    FormManager.hlp.hlpRefresh();
                }
            }
        }

        private void azOff_Click(object sender, EventArgs e)
        {
            /*
            azLight.BackgroundImage = Resources.null256;
            azLight.BackgroundImageLayout = ImageLayout.Stretch;
            isActive = false;
             */ 
        }

        private void bv009_Load(object sender, EventArgs e)
        {
           // if (nakalDalIsOn && nakalAzIsOn) isActive = true;

            if (!FormManager.BK007.getState())
            {
                dalLight.BackgroundImage = Resources.null256;
                dalLight.BackgroundImageLayout = ImageLayout.Stretch;
                azLight.BackgroundImage = Resources.null256;
                azLight.BackgroundImageLayout = ImageLayout.Stretch;
                isActive = false;
            }

            if (FormManager.hlp.helpEnabled())
            {
                if (FormManager.bp62.getState())
                {
                    if (isActive)
                    {
                        FormManager.hlp.setHelpId("end");
                    }
                    else FormManager.hlp.setHelpId("14");
                    FormManager.hlp.hlpRefresh();
                }
                else
                {
                    FormManager.hlp.notSoFast();
                }



                FormManager.hlp.Show();
            }

        }

        private void bv009_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                this.Hide();
            }
        }

        private void bv009_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (isActive)
            {
                  FormManager.hlp.setHelpId("16");
                  foreach (Control x in FormManager.bp61.Controls)
                  {
                      if (x is PictureBox)
                      {
                          ((PictureBox)x).BackgroundImage = Resources.grLight; ;
                          ((PictureBox)x).BackgroundImageLayout = ImageLayout.Stretch;

                      }
                  }

                  foreach (Control x in FormManager.bp62.Controls)
                  {
                      if (x is PictureBox)
                      {
                          ((PictureBox)x).BackgroundImage = Resources.grLight; ;
                          ((PictureBox)x).BackgroundImageLayout = ImageLayout.Stretch;

                      }
                  }

                 
                    

            }
            FormManager.hlp.Hide();
        }

        private void anod1_Click(object sender, EventArgs e)
        {
            if (nakalDalIsOn && nakalAzIsOn)
            {
                FormManager.hlp.setHelpId("end");
                FormManager.hlp.hlpRefresh();
                blokir1.BackgroundImage = Resources.grLight;
                blokir1.BackgroundImageLayout = ImageLayout.Stretch;
                isActive = true;
            }
        }

        private void anod2_Click(object sender, EventArgs e)
        {
            if (nakalDalIsOn && nakalAzIsOn)
            {
                FormManager.hlp.setHelpId("end");
                FormManager.hlp.hlpRefresh();
                blokir2.BackgroundImage = Resources.grLight;
                blokir2.BackgroundImageLayout = ImageLayout.Stretch;
                isActive = true;
            }
        }
    }
}
